package com.ruoyi.web.controller.student_club.domain;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.io.Serializable;

/**
 * @author xc
 */
@Data
public abstract class BaseQueryParam implements Serializable {

    private Long page = 1L;

    private Long size = 20L;

    private String field;

    private Boolean asc = true;

    public <T> Page<T> getPageInfo() {
        Page<T> page = Page.of(this.page, size);
        if (StrUtil.isNotBlank(field)) {
            page.addOrder(new OrderItem(StrUtil.toUnderlineCase(field), asc));
        }
        return page;
    }

}
